Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comparisons to refine Optional types without strict-optional #4523

Merged
merged 7 commits into from Sep 21, 2018

Conversation

msullivan
Copy link
Collaborator

Fixes #4520.

@gvanrossum
Copy link
Member

(Let's hold off on this a bit, we've discovered some problems with it in our own codebase.)

@ilevkivskyi
Copy link
Member

(Let's hold off on this a bit, we've discovered some problems with it in our own codebase.)

Please let me know when the problems are solved, so that I can proceed with a review.

@gvanrossum
Copy link
Member

IIUC that's in @msullivan's court.

@msullivan
Copy link
Collaborator Author

Before this can land, we need to fix #3526, since this change exposes a bunch of instances of it.

@msullivan
Copy link
Collaborator Author

The bad news is that I went and fixed #3526 and it turns out that wasn't actually what was causing trouble internally.
The good news is I also have a fix for the problem which I'll put up shortly.

@msullivan
Copy link
Collaborator Author

@ilevkivskyi this is ready for review now

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I have one unrelated suggestion.

mypy/binder.py Outdated
@@ -271,11 +271,10 @@ def assign_type(self, expr: Expression,
and not restrict_any):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be on a separate line.

@msullivan
Copy link
Collaborator Author

This causes a small handful of errors in internal codebases that will be easy to fix. A couple were weird second-order effects in which doing the refinement meant that a type was no longer a Union and so behaved differently when computing types in a ternary expression. Sigh.

@msullivan msullivan merged commit fed00ef into master Sep 21, 2018
@msullivan msullivan deleted the optional_refine branch September 21, 2018 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants